//目的是抽象和实现分离、解耦

//比如需要画黄色的圆，红色的圆，黄色的方，红色的方
//可以将业务拆分成画图与填充颜色
//之后再随机组合，可扩展性更高

class Color {
  constructor(name) {
    this.name = name
  }
}

class Shape {
  constructor(name, color) {
    this.name = name
    this.color = color
  }
  draw() {
    console.log(`${this.color.name} ${this.name}`)
  }
}

let red = new Color('red')
let yellow = new Color('yellow')
let circle = new Shape('circle', red)
circle.draw()
let triangle = new Shape('triangle', yellow)
triangle.draw()
